<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<div class="mainBody">
    <div class="btnArea floatFix">
        <div class="selectorDiv">
            <div class="selectorName fontDinpro">OS</div>
            <div class="locationGroup listGroupDown listGroup">
                <a class="btnLeft btnPrimary fontDinpro" data-toggle="dropdown" href="javascript:void(0)" link="">
                    <?php
                            echo $os[$cur_os];
                    ?>
                </a>
                <a class="btnRight btnPrimary" data-toggle="dropdown" href="javascript:void(0)"><span class="caretBottom"></span></a>
                <ul class="dropDownList fontDinpro">
                    <?php foreach($os as $k=>$r): ?>
                        <li>
                            <a href="javascript:void(0)" class="fontDinpro" link="<?php echo backend_url($language.'/pack/view/os'); ?>/<?php echo $k; ?>">
                                <?php echo $r; ?>
                            </a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
        </div>
    </div>
    <div class="tableContent">
        <table class="fontDinpro">
            <thead>
            <tr>
                <th style="width: 60px;">TaskId</th>
                <th style="width: 100px;">AppID</th>
                <th>Name</th>
                <th style="width: 100px;">Os</th>
                <th style="width: 120px;">Version</th>
                <th style="width: 100px;">Status</th>
                <th style="width: 210px;">Options</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td style="width: 60px;">TaskId</td>
                <td style="width: 100px;">AppID</td>
                <td>Name</td>
                <td style="width: 100px;">Os</td>
                <td style="width: 120px;">Version</td>
                <td style="width: 100px;">Status</td>
                <td style="width: 210px;">Options</td>
            </tr>
            <?php foreach($list as $v) : ?>
                <tr>
                	<td><?php echo $v['id'];?></td>
                    <td><?php echo $v['appid']; ?></td>
                    <td><?php echo $app_names[$v['appid']]; ?></td>
                   	<td>
                        <?php
                        $className;
                        switch($os[$v['os']]){
                            case "ios":
                                $className = "";
                                break;
                            case "android":
                                $className = "bgAndroidGreen";
                                break;
                            case "wp":
                                $className = "bgBlue";
                                break;
                        }
                        ?>
                        <span class="colorLabel <?php echo $className; ?>"><?php echo $os[$v['os']]; ?></span>
                   	</td>
                    <td><?php echo $v['version']; ?></td>
                    <td>
                    <?php switch($v['status']){
                    	case 0:
                    		echo '<span class="colorLabel bgBlue" style="display: inline-flex;">等待开始</span>';
                    		break;
                    	case 1:
                    		echo '<span class="colorLabel bgOrange" style="display: inline-flex;">进行中</span>';
                    		break;
                    	case 2:
                    		echo '<span class="colorLabel bgGreen" style="display: inline-flex;">已完成</span>';
                    		break;
                    	case 3:
                    		echo '<span class="colorLabel bgBlack" style="display: inline-flex;">暂停</span>';
                    		break;
                    	default:
                    		echo '<span class="colorLabel bgRed" style="display: inline-flex;">出错了</span>';
                    		break;
                    } ?>
                    </td>
                    <td>
                    <button class="tableBtn" onclick="location.href='<?php echo backend_url('pack/view_task/'.$v['id']); ?>'">
                    	<div class="editIcon"></div>View
                	</button>
                   	<?php switch($v['status']){
                    	case 0:
                    		echo '<button class="tableBtn" onclick="location.href=\''. backend_url('pack/update_task_status/'.$v['id'].'/3').'\'"><div class="editIcon"></div>暂停</button>';
                    		break;
                    	case 1:
                    		echo '<button class="tableBtn" style="cursor: default; text-align: center;" type="button">进行中</button>';
                    		break;
                    	case 2:
                    		echo '<button class="tableBtn" style="cursor: default; text-align: center;" type="button">已完成</button>';
                    		break;
                    	case 3:
                    		echo '<button class="tableBtn" onclick="location.href=\''.backend_url('pack/update_task_status/'.$v['id'].'/0').'\'"><div class="editIcon"></div>开始</button>';
                    		break;
                    	default:
                    		echo '<button class="tableBtn" style="cursor: default; text-align: center;" type="button">出错了</button>';
                    		break;
                    } ?>

                    </td>
                </tr>
            <?php endforeach; ?>
            <tr style="height: 33px;"></tr>
            </tbody>
        </table>
    </div>
    <?php if(!empty($pagination)){?><div class="changePage"><?php echo $pagination; ?></div> <?php } ?>
</div>
